<html>
<head><meta charset="utf-8"><title>TyData::Placeholder · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/TyData.3A.3APlaceholder.html">TyData::Placeholder</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="188237840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/TyData%3A%3APlaceholder/near/188237840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/TyData.3A.3APlaceholder.html#188237840">(Feb 14 2020 at 19:26)</a>:</h4>
<p>in the vein of aligning RA's <code>Ty</code> more with Chalk, I'm wondering about placeholders. We used to represent placeholders (for type parameters) in RA as simple indices, but after some refactoring recently, we now just use the (globally) unique ID of the type parameter, which simplifies a few things. Chalk has this representation of universe index + index. I actually don't quite understand what universes are, so</p>
<ol>
<li>what are universes? do they correspond to scopes introducing type parameters? why are they needed?</li>
<li>why does Chalk need to know about them? It seems they are maybe only relevant in case of lifetime placeholders?</li>
</ol>



<a name="188238407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/TyData%3A%3APlaceholder/near/188238407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/TyData.3A.3APlaceholder.html#188238407">(Feb 14 2020 at 19:32)</a>:</h4>
<p>This is something we have to address with rustc, too</p>



<a name="188238462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/TyData%3A%3APlaceholder/near/188238462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/TyData.3A.3APlaceholder.html#188238462">(Feb 14 2020 at 19:33)</a>:</h4>
<p>So, universes are used when dealing with types like <code>for&lt;'a&gt; fn(&amp;'a u32)</code> or when solving goals like <code>forall&lt;T&gt; { if (T: Debug) { Vec&lt;T&gt;: Debug } }</code> (which rust can't currently express, but which arise with GATs)</p>



<a name="188238500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/TyData%3A%3APlaceholder/near/188238500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/TyData.3A.3APlaceholder.html#188238500">(Feb 14 2020 at 19:33)</a>:</h4>
<p>in those cases, we need to 'instantiate' the type parameter <code>T</code> with something, and we use a placeholder for that; the universe helps us track what is in scope</p>



<a name="188238517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/TyData%3A%3APlaceholder/near/188238517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/TyData.3A.3APlaceholder.html#188238517">(Feb 14 2020 at 19:33)</a>:</h4>
<p>there are a few write-ups about it, we should move them to the chalk book</p>



<a name="188238625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/TyData%3A%3APlaceholder/near/188238625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/TyData.3A.3APlaceholder.html#188238625">(Feb 14 2020 at 19:34)</a>:</h4>
<p>in rustc, we have both: we use placeholders like chalk for the "transient lifetimes we create when dealing with higher-ranke things" and we use parameters w/ a def-id for the cases where you can readily enumerate "here are the parametrs in scope" (e.g., when you are checking the body of a function)</p>



<a name="188238694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/TyData%3A%3APlaceholder/near/188238694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/TyData.3A.3APlaceholder.html#188238694">(Feb 14 2020 at 19:35)</a>:</h4>
<p>they are really both the same sort of placeholder, but we treat them slightly differently, and I also think there is some reason we might want that in chalk -- in particular, some of the thoughts I've had about how to handle region solving in a more principled way involve distinguishing between the lifetimes in scope on the fn being checked, and the ifetimes that you instantiate as you deal with higher-ranked types like <code>fn</code></p>



<a name="188238825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/TyData%3A%3APlaceholder/near/188238825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/TyData.3A.3APlaceholder.html#188238825">(Feb 14 2020 at 19:36)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/144729-wg-traits/topic/TyData.3A.3APlaceholder/near/188238517" title="#narrow/stream/144729-wg-traits/topic/TyData.3A.3APlaceholder/near/188238517">said</a>:</p>
<blockquote>
<p>there are a few write-ups about it, we should move them to the chalk book</p>
</blockquote>
<p>yeah, actually there's a link in the doc for <code>UniverseIndex</code> which seems to be outdated</p>



<a name="188240205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/TyData%3A%3APlaceholder/near/188240205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/TyData.3A.3APlaceholder.html#188240205">(Feb 14 2020 at 19:51)</a>:</h4>
<p><span class="user-mention" data-user-id="129457">@Florian Diebold</span> I think the best write-up is <a href="https://rust-lang.github.io/rustc-guide/borrow_check/region_inference/placeholders_and_universes.html" target="_blank" title="https://rust-lang.github.io/rustc-guide/borrow_check/region_inference/placeholders_and_universes.html">this one</a></p>



<a name="188240763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/TyData%3A%3APlaceholder/near/188240763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/TyData.3A.3APlaceholder.html#188240763">(Feb 14 2020 at 19:57)</a>:</h4>
<p>ah yeah, I think I actually read that one before. It seems it only talks about lifetimes, so the vague recollections I had of that didn't seem applicable for types <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="188241060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/TyData%3A%3APlaceholder/near/188241060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/TyData.3A.3APlaceholder.html#188241060">(Feb 14 2020 at 20:00)</a>:</h4>
<p>yeah, the concepts are all applicable</p>



<a name="188241067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/TyData%3A%3APlaceholder/near/188241067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/TyData.3A.3APlaceholder.html#188241067">(Feb 14 2020 at 20:00)</a>:</h4>
<p>but that may not be obvious :)</p>



<a name="188241092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/TyData%3A%3APlaceholder/near/188241092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/TyData.3A.3APlaceholder.html#188241092">(Feb 14 2020 at 20:00)</a>:</h4>
<p>if you have to solve something like <code>exists&lt;T&gt; { forall&lt;U&gt; { T = U } }</code> (which should not be provable...) you would get errors because of universes</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>